package org.szy;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.noear.solon.annotation.Inject;
import org.noear.solon.test.SolonJUnit5Extension;
import org.noear.solon.test.SolonTest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.szy.plugin.gen.result.GenBasicTableResult;
import org.szy.plugin.gen.service.GenBasicService;

import java.util.List;
import java.util.stream.Collectors;


@SolonTest(AdminApp.class)
@ExtendWith(SolonJUnit5Extension.class)
public class genCode {

    Logger log = LoggerFactory.getLogger(genCode.class);
    @Inject
    private GenBasicService genBasicService;

    @Test
    public void text() throws Exception {

        String[] tableNames = {"user_online"};

        List<GenBasicTableResult> tables = genBasicService.tables();

        for (String name : tableNames) {
            List<GenBasicTableResult> collect = tables.stream().filter(i -> i.getTableName().equals(name)).collect(Collectors.toList());
            for (GenBasicTableResult result : collect) {
                genBasicService.textGen(result.getTableName(), result.getTableRemark(), "wangbuhao", "org.szy.plugin.monitor");
            }
        }
    }

}
